﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FantastPlatform.Community.IMode;
using FantastPlatform.Community.Model;
using FantastPlatform.Framework.Service;
using FantastPlatform.Community.IService;
using NHibernate.Criterion;

namespace FantastPlatform.Community.Service
{
    public class PurposeService : DataService<IPurpose, Purpose>, IPurposeService
    {
        public IPurpose GetPurposeByName(string name)
        {
            NHibernate.ICriteria criteria = Session.CreateCriteria(typeof(Purpose));
            criteria.Add(Expression.Eq("Name", name))
               .Add(Expression.Eq("Enable", true));

            return criteria.List<Purpose>().SingleOrDefault();
        }
    }
}
